#pragma once

#include <cmath>
#include "gtest/gtest.h"
#include "DataStructure/Common/Constant.h"
#include "../Gauss2DTria3P.h"

using SG::DataStructure::Common::TOLERANCE;
using SG::FEMSolver::Element::Gauss2DTria3P;

class Gauss2DTria3PTest : public ::testing::Test
{
public:
    void SetUp () override
    {
        m_integForm = Gauss2DTria3P ();
    }
protected:
    Gauss2DTria3P m_integForm;
};

TEST_F (Gauss2DTria3PTest, GetPointSize)
{
    ASSERT_TRUE (3 == m_integForm.GetPointSize ());
}

TEST_F (Gauss2DTria3PTest, GetPoint)
{
    // Test data
    auto point = m_integForm.GetPoint (0);

    // Check Point 1
    ASSERT_NEAR (point.m_weight, 1.0 / 3.0, TOLERANCE);
    ASSERT_NEAR (point.m_x, 1.0 / 6.0, TOLERANCE);
    ASSERT_NEAR (point.m_y, 1.0 / 6.0, TOLERANCE);
    ASSERT_NEAR (point.m_z, 0.0, TOLERANCE);

    // Check Point 2
    point = m_integForm.GetPoint (1);
    ASSERT_NEAR (point.m_weight, 1.0 / 3.0, TOLERANCE);
    ASSERT_NEAR (point.m_x, 2.0 / 3.0, TOLERANCE);
    ASSERT_NEAR (point.m_y, 1.0 / 6.0, TOLERANCE);
    ASSERT_NEAR (point.m_z, 0.0, TOLERANCE);

    // Check Point 3
    point = m_integForm.GetPoint (2);
    ASSERT_NEAR (point.m_weight, 1.0 / 3.0, TOLERANCE);
    ASSERT_NEAR (point.m_x,  1.0 / 6.0, TOLERANCE);
    ASSERT_NEAR (point.m_y,  2.0 / 3.0, TOLERANCE);
    ASSERT_NEAR (point.m_z, 0.0, TOLERANCE);
}